package net.xiduth.game.player.dialogues;

import net.xiduth.Settings;
import net.xiduth.game.player.content.SlayerTask;
import net.xiduth.game.player.content.SlayerTask.Master;

public class Kuradal extends Dialogue {

	int npcId;

	@Override
	public void start() {
		if (!player.isTalkedWithKuradal()) {
			sendEntityDialogue(IS_NPC, "Kuradal", 9085, 9827,
					"Hello, what can I do for you?");
		} else {
			sendEntityDialogue(IS_NPC, "Kuradal", 9085, 9827,
					"What do you need now " + player.getDisplayName() + "?");
		}
	}

	@Override
	public void run(int interfaceId, int componentId) {
		switch (stage) {
		case -1:
			if (!player.isTalkedWithKuradal()) {
				stage = 0;
				sendPlayerDialogue(9827, "Who are you?");
			} else {
				stage = 8;
				sendPlayerDialogue(9827,
						"I would like to ask something about my Task.");
			}
			break;
		case 0:
			stage = 1;
			sendEntityDialogue(
					IS_NPC,
					"Kuradal",
					9085,
					9827,
					"Im the slayer master of <b>"
							+ Settings.SERVER_NAME
							+ "</b>, Kuradal! I give out slayer task to the best warriors around!");
			break;
		case 1:
			stage = 2;
			sendPlayerDialogue(9827, "Can I please have a task?");
			break;
		case 2:
			stage = 3;
			sendEntityDialogue(IS_NPC, "Kuradal", 9085, 9827,
					"Of course, here is your task..");
			break;
		case 3:
			if (player.getTask() == null) {
				SlayerTask.random(player, Master.KURADAL);
				sendEntityDialogue(IS_NPC, "Kuradal", 9085, 9827,
						"Your task is to kill "
								+ player.getTask().getTaskAmount() + " "
								+ player.getTask().getName().toLowerCase()
								+ "s.");
				player.setTalkedWithKuradal();
				stage = 7;
			} else {
				sendEntityDialogue(IS_NPC, "Kuradal", 9085, 9827,
						"You already have a task that you need to complete! ",
						"Your task is to kill "
								+ player.getTask().getTaskAmount() + " "
								+ player.getTask().getName().toLowerCase()
								+ "s.");
				player.setTalkedWithKuradal();
				stage = 4;
			}
			break;
		case 4:
			stage = 5;
			sendPlayerDialogue(9827, "Can you show me where I can kill "
					+ player.getTask().getName() + "?");
			break;
		case 5:
			stage = 6;
			sendEntityDialogue(IS_NPC, "Kuradal", 9085, 9827,
					"I have no information for your task, sorry.");
			break;
		case 6:
			stage = 7;
			sendPlayerDialogue(9827,
					"Alright, I will use the forums if I need any help!");
			break;
		case 7: /* Offical end of Dialogue */
			end();
			break;
		case 8:
			stage = 9;
			sendEntityDialogue(IS_NPC, "Kuradal", 9085, 9827,
					"Alright, what can I help you with?");
			break;
		case 9:
			stage = 10;
			sendOptionsDialogue(SEND_DEFAULT_OPTIONS_TITLE,
					"I have finished my Task!", "Can you change my Task?",
					"I dont remember my Task.",
					"I would like to purchase a Slayer Helmet.",
					"I would like to have an Enchanted Gem!");
			break;
		case 10:
			switch (componentId) {
			case OPTION_1:
				stage = 11;
				sendPlayerDialogue(9827,
						"I have completed the task you assigned me!");
				break;
			case OPTION_2:
				stage = 12;
				sendPlayerDialogue(9827,
						"I would like to have a new task from you.");
				break;
			case OPTION_3:
				stage = 21;
				sendPlayerDialogue(9827,
						"I don't remember the task you gave me.");
				break;
			case OPTION_4:
				stage = 24;
				sendPlayerDialogue(9827,
						"I would like to purchase a Slayer Helmet.");
				break;
			case OPTION_5:
				stage = 25;
				sendPlayerDialogue(9827,
						"I would like to have an Enchantment Gem.");
				break;
			}
			break;
		case 11:
			stage = 13;
			if (player.getTask() == null) {
				sendEntityDialogue(IS_NPC, "Kuradal", 9085, 9827,
						"Very good, would you like to have a new task?");
			} else {
				sendEntityDialogue(IS_NPC, "Kuradal", 9085, 9827,
						"No you haven't warrior.");
				stage = 7;
			}
			break;
		case 12:
			stage = 14;
			sendEntityDialogue(IS_NPC, "Kuradal", 9085, 9827,
					"I can assign a new task for a fee of 1,000,000 gp.");
			break;
		case 13:
			stage = 15;
			sendOptionsDialogue(SEND_DEFAULT_OPTIONS_TITLE, "Yes", "No thanks");
			break;
		case 14:
			stage = 16;
			sendOptionsDialogue(
					"Do you want to change your task for 1,000,000 gp?", "Yes",
					"No thanks");
			break;
		case 15:
			switch (componentId) {
			case OPTION_1:
				stage = 17;
				sendPlayerDialogue(9827, "Yes please.");
				break;
			case OPTION_2:
				stage = 18;
				sendPlayerDialogue(9827, "No thanks.");
				break;
			}
			break;
		case 16:
			switch (componentId) {
			case OPTION_1:
				stage = 19;
				sendPlayerDialogue(9827, "Yes please.");
				break;
			case OPTION_2:
				stage = 20;
				sendPlayerDialogue(9827, "No thanks.");
				break;
			}
			break;
		case 17:
			SlayerTask.random(player, Master.KURADAL);
			sendEntityDialogue(IS_NPC, "Kuradal", 9085, 9827,
					"Your new slayertask is to kill "
							+ player.getTask().getTaskAmount() + " "
							+ player.getTask().getName().toLowerCase() + "s..");
			stage = 7;
			break;
		case 18:
			sendEntityDialogue(IS_NPC, "Kuradal", 9085, 9827,
					"Okay, see you soon!");
			stage = 7;
			break;
		case 19:
			if (player.getInventory().containsItem(995, 1000000)) {
				player.getInventory().deleteItem(995, 1000000);
				SlayerTask.random(player, Master.KURADAL);
				sendEntityDialogue(IS_NPC, "Kuradal", 9085, 9827,
						"Your new slayertask is to kill "
								+ player.getTask().getTaskAmount() + " "
								+ player.getTask().getName().toLowerCase()
								+ "s..");
				stage = 7;
			} else {
				sendEntityDialogue(IS_NPC, "Kuradal", 9085, 9827,
						"You dont have 1,000,000 gold, come back later.");
				stage = 7;
			}
			break;
		case 20:
			sendEntityDialogue(IS_NPC, "Kuradal", 9085, 9827,
					"Sorry to hear, come back later.");
			stage = 7;
			break;
		case 21:
			sendEntityDialogue(IS_NPC, "Kuradal", 9085, 9827,
					"Your new task is to kill..");
			stage = 22;
			break;
		case 22:
			sendEntityDialogue(IS_NPC, "Kuradal", 9085, 9827,
					"Your slayertask is to kill "
							+ player.getTask().getTaskAmount() + " "
							+ player.getTask().getName().toLowerCase()
							+ "s. Please remember your task next time.");
			stage = 23;
			break;
		case 23:
			sendPlayerDialogue(9827, "Thank you Kuradal!");
			stage = 7;
			break;
		case 24:
			sendEntityDialogue(IS_NPC, "Kuradal", 9085, 9827, "Here you go!");
			if (player.getSlayerPoints() >= 400) {
				player.getInventory().addItem(15492, 1);
				player.setSlayerPoints(player.getSlayerPoints() - 400);
				stage = 23;
			} else {
				sendEntityDialogue(IS_NPC, "Kuradal", 9085, 9827,
						"You need 400 Points to purchase the Full Slayer Helmet.");
				stage = 23;
			}
			break;
		case 25:
			sendEntityDialogue(IS_NPC, "Kuradal", 9085, 9827, "Here you go!");
			if (player.getSlayerPoints() >= 0) {
				player.getInventory().addItem(4155, 1);
				stage = 23;
			}
			break;
		}
	}

	@Override
	public void finish() {
		// TODO Auto-generated method stub

	}

}